import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import KFold, cross_val_score
from sklearn.preprocessing import MinMaxScaler
from sklearn.ensemble import RandomForestClassifier

data_set = pd.read_csv('pima-indians-diabetes.csv')
feature_columns = ['pregnant', 'glucose', 'bp', 'skin', 'insulin', 'bmi', 'pedigree', 'age']
X = data_set[feature_columns]
y = data_set.label

# 选择最好用的参数匹配去用
model_regression = LogisticRegression(solver='liblinear')

kflod = KFold(n_splits=10)

cv_score = cross_val_score(model_regression, X, y, cv=kflod)
print('LogisticRegression:')
print('mean: %.2f  var: %.2f  std: %.2f' % (cv_score.mean(), cv_score.var(), cv_score.std()))

model_random = RandomForestClassifier()

cv_score = cross_val_score(model_random, X, y, cv=kflod)
print('RandomForestClassifier:')
print('mean: %.2f  var: %.2f  std: %.2f' % (cv_score.mean(), cv_score.var(), cv_score.std()))

